fix(dashboard): show remaining totals in usage donuts#303
fix(dashboard): show remaining totals in usage donuts#303Daltonganger wants to merge 4 commits intoSoju06:mainfrom
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec488ecb71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ? applySecondaryConstraint(rawPrimaryItems, secondaryUsageItems) | ||
| : rawPrimaryItems, | ||
| secondaryUsageItems, | ||
| primaryUsageTotal: overview.summary.primaryWindow.remainingCredits, |
There was a problem hiding this comment.
Derive primary donut total from constrained items
When the weekly window is tighter than the 5h window, applySecondaryConstraint reduces primaryUsageItems, but primaryUsageTotal still uses the unconstrained overview.summary.primaryWindow.remainingCredits. In that case the donut center ("Remaining") and consumed = total - usedSum become inconsistent with the displayed slices, so the chart overstates usable 5h remaining and introduces a synthetic consumed segment. Compute the total from the constrained primary items (or an equivalently constrained aggregate) so totals and slices stay aligned.
Useful? React with 👍 / 👎.
Summary
Testing
bun run test -- src/features/dashboard/utils.test.ts src/features/dashboard/components/usage-donuts.test.tsxbun run lint -- src/features/dashboard/components/dashboard-page.tsx src/features/dashboard/utils.ts src/features/dashboard/utils.test.tsbun run typecheck